import pytest
from types import NoneType
from game import perform_move, EMPTY_MARK
list_for_move = [5, 1, 7, 3, 9, 2, 6, 4, 11, EMPTY_MARK, 15, 8, 10, 13, 14, 12]
list_no_move_UpLeft = [EMPTY_MARK, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
list_no_move_DownRight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, EMPTY_MARK]


@pytest.mark.parametrize('field, key, result', [
        (list_for_move.copy(), 'w', list), 
        (list_no_move_DownRight.copy(), 'w', list), 
        (list_no_move_UpLeft.copy(), 'w', NoneType)])
def test_move_up(field, key, result):    
    assert type(perform_move(field, key))== result

@pytest.mark.parametrize('field, key, result', [
    (list_for_move.copy(), 's', list), 
    (list_no_move_UpLeft.copy(), 's', list), 
    (list_no_move_DownRight.copy(), 's', NoneType)])
def test_move_down(field, key, result):
    assert type(perform_move(field, key))== result

@pytest.mark.parametrize('field, key, result', [
    (list_for_move.copy(), 'd', list), 
    (list_no_move_UpLeft.copy(), 'd', list), 
    (list_no_move_DownRight.copy(), 'd', NoneType)])
def test_move_right(field, key, result):
    assert type(perform_move(field, key))== result

@pytest.mark.parametrize('field, key, result', [
    (list_for_move.copy(), 'a', list), 
    (list_no_move_DownRight.copy(), 'a', list), 
    (list_no_move_UpLeft.copy(), 'a', NoneType)])
def test_move_left(field, key, result):
    assert type(perform_move(field, key))== result

@pytest.mark.parametrize('field, key, result', [
    (list_for_move.copy(), 'g', NoneType), 
    (list_no_move_DownRight.copy(), '123', NoneType), 
    (list_no_move_UpLeft.copy(), '4', NoneType)])
def test_move_unknown(field, key, result):
    assert type(perform_move(field, key))== result